<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <title>INTERFACE_AUTOMOC_MACRO_NAMES &mdash; CMake 4.1.1 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=a2c47e09" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css?v=4d06bd55" />
    
    <script src="../_static/documentation_options.js?v=e6a937a4"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="INTERFACE_AUTOUIC_OPTIONS" href="INTERFACE_AUTOUIC_OPTIONS.html" />
    <link rel="prev" title="INSTALL_RPATH_USE_LINK_PATH" href="INSTALL_RPATH_USE_LINK_PATH.html" />
 

  </head><body>
    <input id="sidebar-check" type="checkbox" />
    <label id="sidebar-overlay" for="sidebar-check"></label>



    <div class="related relbar1" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="INTERFACE_AUTOUIC_OPTIONS.html" title="INTERFACE_AUTOUIC_OPTIONS"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="INSTALL_RPATH_USE_LINK_PATH.html" title="INSTALL_RPATH_USE_LINK_PATH"
             accesskey="P">previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-properties.7.html" accesskey="U">cmake-properties(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">INTERFACE_AUTOMOC_MACRO_NAMES</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="interface-automoc-macro-names">
<span id="prop_tgt:INTERFACE_AUTOMOC_MACRO_NAMES"></span><h1>INTERFACE_AUTOMOC_MACRO_NAMES<a class="headerlink" href="#interface-automoc-macro-names" title="Link to this heading">¶</a></h1>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.27.</span></p>
</div>
<p>A <a class="reference internal" href="../manual/cmake-language.7.html#cmake-language-lists"><span class="std std-ref">semicolon-separated list</span></a> of macro names for
<span class="target" id="index-0-prop_tgt:AUTOMOC"></span><a class="reference internal" href="AUTOMOC.html#prop_tgt:AUTOMOC" title="AUTOMOC"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">AUTOMOC</span></code></a> to be propagated to consumers.</p>
<p>When a target with <span class="target" id="index-1-prop_tgt:AUTOMOC"></span><a class="reference internal" href="AUTOMOC.html#prop_tgt:AUTOMOC" title="AUTOMOC"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">AUTOMOC</span></code></a> enabled links to a library that sets
<code class="docutils literal notranslate"><span class="pre">INTERFACE_AUTOMOC_MACRO_NAMES</span></code>, the target inherits the listed macro names
and merges them with those specified in its own <span class="target" id="index-0-prop_tgt:AUTOMOC_MACRO_NAMES"></span><a class="reference internal" href="AUTOMOC_MACRO_NAMES.html#prop_tgt:AUTOMOC_MACRO_NAMES" title="AUTOMOC_MACRO_NAMES"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">AUTOMOC_MACRO_NAMES</span></code></a>
property.  The target will then automatically generate MOC files for source
files that contain the inherited macro names too, not just the macro names
specified in its own <span class="target" id="index-1-prop_tgt:AUTOMOC_MACRO_NAMES"></span><a class="reference internal" href="AUTOMOC_MACRO_NAMES.html#prop_tgt:AUTOMOC_MACRO_NAMES" title="AUTOMOC_MACRO_NAMES"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">AUTOMOC_MACRO_NAMES</span></code></a> property.</p>
<p>By default <code class="docutils literal notranslate"><span class="pre">INTERFACE_AUTOMOC_MACRO_NAMES</span></code> is empty.</p>
<p>See the <span class="target" id="index-0-manual:cmake-qt(7)"></span><a class="reference internal" href="../manual/cmake-qt.7.html#manual:cmake-qt(7)" title="cmake-qt(7)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">cmake-qt(7)</span></code></a> manual for more information on using CMake
with Qt.</p>
<section id="example-1">
<h2>Example 1<a class="headerlink" href="#example-1" title="Link to this heading">¶</a></h2>
<p>In this example, <code class="docutils literal notranslate"><span class="pre">myapp</span></code> inherits the macro names <code class="docutils literal notranslate"><span class="pre">STATIC_LIB_1</span></code> and
<code class="docutils literal notranslate"><span class="pre">STATIC_LIB_2</span></code> from <code class="docutils literal notranslate"><span class="pre">static_lib</span></code>.  The <code class="docutils literal notranslate"><span class="pre">moc</span></code> tool will then automatically
be run on any of the <code class="docutils literal notranslate"><span class="pre">myapp</span></code> sources which contain <code class="docutils literal notranslate"><span class="pre">STATIC_LIB_1</span></code> or
<code class="docutils literal notranslate"><span class="pre">STATIC_LIB_2</span></code>.</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">set(</span><span class="no">AUTOMOC</span><span class="w"> </span><span class="no">ON</span><span class="nf">)</span>
<span class="nf">add_executable(</span><span class="nb">myapp</span><span class="w"> </span><span class="nb">main.cpp</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">myapp</span><span class="w"> </span><span class="no">PRIVATE</span><span class="w"> </span><span class="nb">static_lib</span><span class="nf">)</span>

<span class="nf">add_library(</span><span class="nb">static_lib</span><span class="w"> </span><span class="no">STATIC</span><span class="w"> </span><span class="nb">static.cpp</span><span class="nf">)</span>
<span class="nf">set_property(</span><span class="no">TARGET</span><span class="w"> </span><span class="nb">static_lib</span><span class="w"> </span><span class="no">PROPERTY</span>
<span class="w">  </span><span class="no">INTERFACE_AUTOMOC_MACRO_NAMES</span><span class="w"> </span><span class="s">&quot;STATIC_LIB_1;STATIC_LIB_2&quot;</span>
<span class="nf">)</span>
</pre></div>
</div>
</section>
<section id="example-2">
<h2>Example 2<a class="headerlink" href="#example-2" title="Link to this heading">¶</a></h2>
<p>In this example, the <code class="docutils literal notranslate"><span class="pre">INTERFACE_AUTOMOC_MACRO_NAMES</span></code> target property of the
various <code class="docutils literal notranslate"><span class="pre">*_deep_lib</span></code> libraries will propagate to <code class="docutils literal notranslate"><span class="pre">shared_lib</span></code>,
<code class="docutils literal notranslate"><span class="pre">static_lib</span></code> and <code class="docutils literal notranslate"><span class="pre">interface_lib</span></code>.  Because the linking relationships are
specified as <code class="docutils literal notranslate"><span class="pre">PUBLIC</span></code> and <code class="docutils literal notranslate"><span class="pre">INTERFACE</span></code>, those macro names will also further
propagate transitively up to <code class="docutils literal notranslate"><span class="pre">app</span></code>.</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">set(</span><span class="no">AUTOMOC</span><span class="w"> </span><span class="no">ON</span><span class="nf">)</span>

<span class="nf">add_library(</span><span class="nb">shared_deep_lib</span><span class="w"> </span><span class="no">SHARED</span><span class="w"> </span><span class="nb">deep_lib.cpp</span><span class="nf">)</span>
<span class="nf">add_library(</span><span class="nb">static_deep_lib</span><span class="w"> </span><span class="no">STATIC</span><span class="w"> </span><span class="nb">deep_lib.cpp</span><span class="nf">)</span>
<span class="nf">add_library(</span><span class="nb">interface_deep_lib</span><span class="w"> </span><span class="no">INTERFACE</span><span class="nf">)</span>

<span class="nf">set_property(</span><span class="no">TARGET</span><span class="w"> </span><span class="nb">shared_deep_lib</span><span class="w"> </span><span class="no">PROPERTY</span>
<span class="w">  </span><span class="no">INTERFACE_AUTOMOC_MACRO_NAMES</span><span class="w"> </span><span class="s">&quot;SHARED_LINK_LIB&quot;</span>
<span class="nf">)</span>
<span class="nf">set_property(</span><span class="no">TARGET</span><span class="w"> </span><span class="nb">static_deep_lib</span><span class="w"> </span><span class="no">PROPERTY</span>
<span class="w">  </span><span class="no">INTERFACE_AUTOMOC_MACRO_NAMES</span><span class="w"> </span><span class="s">&quot;STATIC_LINK_LIB&quot;</span>
<span class="nf">)</span>
<span class="nf">set_property(</span><span class="no">TARGET</span><span class="w"> </span><span class="nb">interface_deep_lib</span><span class="w"> </span><span class="no">PROPERTY</span>
<span class="w">  </span><span class="no">INTERFACE_AUTOMOC_MACRO_NAMES</span><span class="w"> </span><span class="s">&quot;INTERFACE_LINK_LIB&quot;</span>
<span class="nf">)</span>

<span class="nf">add_library(</span><span class="nb">shared_lib</span><span class="w"> </span><span class="no">SHARED</span><span class="w"> </span><span class="nb">lib.cpp</span><span class="nf">)</span>
<span class="nf">add_library(</span><span class="nb">static_lib</span><span class="w"> </span><span class="no">STATIC</span><span class="w"> </span><span class="nb">lib.cpp</span><span class="nf">)</span>
<span class="nf">add_library(</span><span class="nb">interface_lib</span><span class="w"> </span><span class="no">INTERFACE</span><span class="nf">)</span>

<span class="c"># PUBLIC and INTERFACE here ensure the macro names propagate to any</span>
<span class="c"># consumers of shared_lib, static_lib or interface_lib too</span>
<span class="nf">target_link_libraries(</span><span class="nb">shared_lib</span><span class="w"> </span><span class="no">PUBLIC</span><span class="w"> </span><span class="nb">shared_deep_lib</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">static_lib</span><span class="w"> </span><span class="no">PUBLIC</span><span class="w"> </span><span class="nb">static_deep_lib</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">interface_lib</span><span class="w"> </span><span class="no">INTERFACE</span><span class="w"> </span><span class="nb">interface_deep_lib</span><span class="nf">)</span>

<span class="c"># This consumer will receive all three of the above custom macro names as</span>
<span class="c"># transitive usage requirements</span>
<span class="nf">add_executable(</span><span class="nb">app</span><span class="w"> </span><span class="nb">main.cpp</span><span class="nf">)</span>
<span class="nf">target_link_libraries(</span><span class="nb">app</span><span class="w"> </span><span class="no">PRIVATE</span><span class="w"> </span><span class="nb">shared_lib</span><span class="w"> </span><span class="nb">static_lib</span><span class="w"> </span><span class="nb">interface_lib</span><span class="nf">)</span>
</pre></div>
</div>
<p>In the above:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">shared_lib</span></code> sources will be processed by <code class="docutils literal notranslate"><span class="pre">moc</span></code> if they contain
<code class="docutils literal notranslate"><span class="pre">SHARED_LINK_LIB</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">static_lib</span></code> sources will be processed by <code class="docutils literal notranslate"><span class="pre">moc</span></code> if they contain
<code class="docutils literal notranslate"><span class="pre">STATIC_LINK_LIB</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">app</span></code> sources will be processed by <code class="docutils literal notranslate"><span class="pre">moc</span></code> if they contain
<code class="docutils literal notranslate"><span class="pre">SHARED_LINK_LIB</span></code>, <code class="docutils literal notranslate"><span class="pre">STATIC_LINK_LIB</span></code> or <code class="docutils literal notranslate"><span class="pre">INTERFACE_LINK_LIB</span></code>.</p></li>
</ul>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3>Table of Contents</h3>
    <ul>
<li><a class="reference internal" href="#">INTERFACE_AUTOMOC_MACRO_NAMES</a><ul>
<li><a class="reference internal" href="#example-1">Example 1</a></li>
<li><a class="reference internal" href="#example-2">Example 2</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="INSTALL_RPATH_USE_LINK_PATH.html"
                          title="previous chapter">INSTALL_RPATH_USE_LINK_PATH</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="INTERFACE_AUTOUIC_OPTIONS.html"
                          title="next chapter">INTERFACE_AUTOUIC_OPTIONS</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/prop_tgt/INTERFACE_AUTOMOC_MACRO_NAMES.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="INTERFACE_AUTOUIC_OPTIONS.html" title="INTERFACE_AUTOUIC_OPTIONS"
             >next</a> |</li>
        <li class="right" >
          <a href="INSTALL_RPATH_USE_LINK_PATH.html" title="INSTALL_RPATH_USE_LINK_PATH"
             >previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-properties.7.html" >cmake-properties(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">INTERFACE_AUTOMOC_MACRO_NAMES</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
    &#169; Copyright 2000-2025 Kitware, Inc. and Contributors.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
    </div>
<script type="text/javascript">
(function() {
  "use strict";
  const hide = () => document.getElementById("sidebar-check").checked = false;
  addEventListener("keydown", e => (e.key === "Escape") && hide());
  addEventListener("click", e => (e.target.tagName === "A") && hide());
  addEventListener("hashchange", hide)
})();
</script>
  </body>
</html>